<?php
include 'ControllerInterface.php';         
include 'Request.php';       
include  'Constants.inc.php' ;
include SMARTY;

abstract class AbstractController implements  ControllerInterface{
            private $name;
            
            protected $session;
            protected $request;         
            
            protected $model;
            protected $controller; 
            protected $view; 
            protected $template;
            
            private $parent; 
            
            
            
            /*
                  name-  nazwa kontrolera
                  request - objektodpowiedzi http
                  session - sesja(jesli wymagana) 
            */
            public function __construct($name,$session=null){
                $this->session=$session;
                $this->name=$name;
                
                $this->request=new Request($name,$session);
                $this->controller=array();
                $this->parent=null;
                  
            }
            
            
            public function getHttp(){
                  foreach($this->controller as $controller ){
                        $controller->getHttp();
                  }
                  
                  $this->createHttp(); 
            }
            
            
            
            
            public function getModel(){
                  foreach($this->controller as $controller ){
                        $controller->getModel();
                  }
                  
                   $this->createModel(); 
            }
            
            
            
            
            public function getParent(){
                  return $this->parrent;
            }
            
            
            public function setParent($controller){
                  $this->parent=$controller;
            }
            
            public function addController($controller){
                  $this->controller[]=$controller;
                  $controller->setParent($this);
            }
            
            
            public function setName($name){
                  $this->name=$name;
            }
            
            public function getName(){
                  return $this->name;
            }
            
}

?>
